<?php require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/FJK46JDE/modconf.php");
MYTCONN();
	$memberID = 0;
$qrOffice = "SELECT OriNumero AS ID, OriNombre AS NAME FROM officeschema.origenes WHERE OriTipo = 2 AND OriNumero >= 800";
	
	if (isset($_GET['RSID'])) { 
		$GETDATA = $GLOBALS['MYT']->db_array("SELECT * FROM systemoffice.timeclock_staffoff
			INNER JOIN systemoffice.staff_move ON smv_UserID = tsv_Member AND DATE(smv_DateRequest) = DATE(tsv_DateTime)
			WHERE tsv_ID = {$_GET['RSID']}");
		$memberID = $GETDATA[1]['smv_UserID'];
		$_GET['SMID'] = $memberID;

	} else {
		$GETDATA[1]['smv_DomainDst'] = '';
		$GETDATA[1]['smv_Motive'] = '';
		$GETDATA[1]['smv_DateMov'] = '';
		$GETDATA[1]['tsv_DateEnd'] = '';
		$GETDATA[1]['smv_Observations'] = '';
	}
	if (isset($_GET['trsf_Member'])) { $memberID = $_GET['trsf_Member']; }
	
	form_pr('staffmv','','','post');
	mn_field('hidden','ED','smv_ID',0,'','','','');
	echo '<div style="height:440px;">
	<div id="SelcMember" class="Line">';
	if ($memberID == 0) { 
		include($MODPAD.'Lib/sel_memberrsm.php');
	} else {
		include($MODPAD.'Lib/get_memberrsm.php');
	}
	echo '</div>';
	
	echo '<table>
	<tr><td>Loja de destino:</td><td>'; mn_field('select','ED','smv_Domain',$GETDATA[1]['smv_DomainDst'],$qrOffice,'','False',''); echo '</td></tr>
	<tr><td>Motivo da mudanÇa: </td><td>'; mn_field('text','ED','smv_Motive',$GETDATA[1]['smv_Motive'],'50','40','False',''); echo '</td></tr>
	<tr><td>Data da MudanÇa: </td><td>'; 
		mn_field('date','ED','smv_DateMov',$GETDATA[1]['smv_DateMov'],'staffmv','8','False','');
	echo '</td></tr><tr><td>';
	echo 'Periodo de Permanencia: </td><td>'; 
		mn_field('checkbox','ED','tsv_noend','1','','','','" onclick="
			if(this.checked==true) {document.staffmv.tsv_DateEnd.disabled=true} else {document.staffmv.tsv_DateEnd.disabled=false}'); echo ' Sem previsao | ';
		mn_field('date','ED','tsv_DateEnd',$GETDATA[1]['tsv_DateEnd'],'staffmv','8','False','');
	echo '</td></tr><tr><td style="vertical-align:top">';
	echo 'Observacoes:</td><td>'; mn_field('textarea','ED','smv_Observations',$GETDATA[1]['smv_Observations'],'66','14','False','');	 
	echo '</td></tr></table>
	</div>
	<div id="transf_result"></div>';

 mn_field('button','ED','Save','Guardar','','','','" style="width:100%;height:20" onClick="
	if (typeof(document.staffmv.MemberID) == \'undefined\') {
		alert(\'Tem de escolher um funcionario.\');	
	} else if (document.staffmv.MemberDomain.value == document.staffmv.smv_Domain.options[document.staffmv.smv_Domain.selectedIndex].value) {
		alert(\'A loja de destino nao e valida.\');	
	} else {
	document.staffmv.action=\''.$GLOBALS['URL'].'_response/rsproxy.php?pr=rh_membertransfer\';
	subform(\'staffmv\',\'transf_result\');
	}');?>

</form>